# * coding: utf-8 *
import os
import json
import pandas as pd
import sys
import io

sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')

if __name__ == '__main__':
    dir_path = "E:\\projects\\江苏数据"
    for channel in os.listdir(dir_path):
        if channel != "227": continue
        print(channel)
        out_json = os.path.join(dir_path, channel, "out.json")
        with open(out_json, "r", encoding="utf-8") as f:
            json_data = json.load(f)

        for row in json_data:
            middle_res = row["middle_res"]
            if middle_res:
                for res in middle_res:
                    print(res)
        # 其他操作
        # df = pd.read_csv(cut_csv)
        # merged_info = df.to_dict(orient='records')
        # relation_info = generate_content_relation(merged_info)
        # merged_info = concat_content(relation_info)
        # relation_info = find_adv_edge(merged_info, transcript)
        # with open(out_csv[:-4]+".json", "w", encoding="utf-8") as f:
        #     json_data = json.dumps(relation_info, indent=4, ensure_ascii=False)
        #     f.write(json_data)
        # merged_info = pd.DataFrame(merged_info)
        # merged_info.to_csv(out_csv, index=False)
        break
